public class Demo1 {
    public static void main(String[] args) throws InterruptedException {
        Object obj = new Object();
        Thread t1 = new Thread(() -> {
           synchronized (obj){
               for (int i = 0; i < 10; i++) {
                   System.out.print("A");
               }
           }
        });
        Thread t2 = new Thread(() -> {
            synchronized (obj){
                for (int i = 0; i < 10; i++) {
                    System.out.print("B");
                }
            }
        });
        Thread t3 = new Thread(() -> {
            synchronized (obj){
                for (int i = 0; i < 10; i++) {
                    System.out.print("C");
                }
            }
        });

        t1.start();
        t2.start();
        t3.start();
        t1.join();
        t2.join();
        t3.join();
        System.out.println();

    }
}
